import java.util.Scanner;

public class Main {
    public static int getIndexOf(String s, String m){
        if (s == null || m == null || m.length() < 1 || s.length() < m.length()) {
            return -1;
        }
        char[] str1 = s.toCharArray();
        char[] str2 = m.toCharArray();
        int i1 = 0;// s中比对到的位置
        int i2 = 0;// m中比对到的位置
        int[] next = getNextArray(str2);
        //跳出while的条件：要么x越界，要么y越界
        while (i1 < str1.length && i2 < str2.length) {
            if (str1[i1] == str2[i2]) {
                i1++;
                i2++;
            } else if (next[i2] == -1) {// 当x与y不匹配，并且[y] == -1,y == 0
                i1++;
            } else {
                i2 = next[i2];// y 位置next数组的值不是-1
            }
        }
        return i2 == str2.length ? i1 - i2 : -1;
    }

    public static int[] getNextArray(char[] ms) {
        if (ms.length == 1) {
            return new int[] { -1 };
        }
        int[] next = new int[ms.length];
        next[0] = -1;
        next[1] = 0;
        int i = 2;
        int cn = 0;
        while (i < next.length) {
            if (ms[i - 1] == ms[cn]) {
                next[i++] = ++cn;
            } else if (cn > 0) {
                cn = next[cn];
            } else {
                next[i++] = 0;
            }
        }
        return next;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int res = -1;
        String s = sc.next();
        int lens = s.length();
        for(int jz = 2; jz <=16; jz ++)
        {
            StringBuffer T=new StringBuffer();
            for(int i = 1; i <= n; i ++)
            {
                int cnt = 0,temp = i;
                int num[] = new int[100];
                ///生成某进制的逆序
                while(temp > 0)
                {
                    num[cnt ++] = temp % jz;
                    temp/=jz;
                }
                ///生成进制
                for(int j = cnt - 1; j >= 0; j --)
                {
                    if(num[j] < 10)
                        T.append((char)(num[j] + '0'));
                    else
                        T.append((char)(num[j] - 10 + 'A'));
                }

            }

            res = Math.max(res,getIndexOf(T.toString(),s));
            if(res >= 0)
            {
                System.out.println("yes");
                break;
            }

        }
        if(res < 0) System.out.println("no");
    }

}
